package com.feng.cloud.test.feign.fallback;

import com.feng.cloud.common.response.RestResponse;
import com.feng.cloud.common.response.TableResultResponse;
import com.feng.cloud.system.entity.SystemUser;
import com.feng.cloud.test.feign.UserService;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.util.Map;

/**
 * Feign回退,可返回兜底数据
 * @author feng_
 */
@Slf4j
@Component
public class UserServiceFallback implements FallbackFactory<UserService> {

    @Override
    public UserService create(Throwable throwable) {
        return new UserService() {
            @Override
            public TableResultResponse<SystemUser> selectPage(Map<String, Object> params) {
                return new TableResultResponse<>();
            }

            @Override
            public RestResponse<SystemUser> add(@Valid SystemUser user) {
                return null;
            }

            @Override
            public RestResponse<SystemUser> update(@Valid SystemUser user) {
                return null;
            }

            @Override
            public RestResponse<Void> update(@NotBlank(message = "{required}") String userIds) {
                return null;
            }

            @Override
            public RestResponse<SystemUser> updateUserProfileById(@Valid SystemUser user) {
                return null;
            }
        };
    }
}